package aliyunCli

import (
	"fmt"
	"tushare/conf"

	openapi "github.com/alibabacloud-go/darabonba-openapi/client"
	ecs20140526 "github.com/alibabacloud-go/ecs-20140526/v2/client"
	"github.com/alibabacloud-go/tea/tea"
)

type AllocatePublicIpAddress struct{}

func (ai AllocatePublicIpAddress) AllocatePublicIpAddress(instanceId string) {

	config := &openapi.Config{
		// 您的AccessKey ID
		AccessKeyId: tea.String(conf.AccessKeyID),
		// 您的AccessKey Secret
		AccessKeySecret: tea.String(conf.AccessKeySecret),
	}
	// 访问的域名
	config.Endpoint = tea.String("ecs-cn-hangzhou.aliyuncs.com")
	clientC := &ecs20140526.Client{}
	clientC, _err := ecs20140526.NewClient(config)
	if _err != nil {
		fmt.Println(_err)
	}

	allocatePublicIpAddressRequest := &ecs20140526.AllocatePublicIpAddressRequest{
		InstanceId: tea.String(instanceId),
	}
	// 复制代码运行请自行打印 API 的返回值
	_, _err = clientC.AllocatePublicIpAddress(allocatePublicIpAddressRequest)
	if _err != nil {
		fmt.Println(_err)
	}

}
